<?php

/**
 * Session.php
 * 
 * @author      :   QuangLT
 * @name        :   Plun_Plugin_Auth
 * @version     :   1.0
 * @copyright   :   Plun-Asia
 */
 
class Plun_Session extends Zend_Session
{    
    protected static $_instance = null;
    
    public static function init()
    {        
        if (self::$_instance === null)
        {
            self::$_instance = new Zend_Session_Namespace('system', true);
        }        
    }
    
    /**
     * Set session
     * @param string $key
     * @param mixed $value
     * @throws Plun_Exception
     */
    public static function set($key, $value)
    {
        if (self::$_instance !== null)
        {            
            self::$_instance->{$key} = $value;
            return true;
        }           
        
        throw new Plun_Exception('Session was not initialized!');
    }
    
    /**
     * Retrieve session
     * @param string $key
     * @return mixed
     * @throws Plun_Exception
     */
    public static function get($key)
    {
        if (self::$_instance !== null)
        {            
            return self::$_instance->{$key};
        }
        
        throw new Plun_Exception('Session was not initialized!');
    }
}